package com.xls.commonlibrary.http;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.core.ObservableTransformer;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class Transformer<T> implements ObservableTransformer<T, T> {

    @Override
    public @NonNull ObservableSource<T> apply(@NonNull Observable<T> upstream) {
        // 复用这两行变换
        return
                upstream.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                ;
    }

    public static <T> Transformer<T> transform() {
        return new Transformer<>();
    }
}
